package com.sunspring.zdcall.service.impl;

import com.sunspring.zdcall.entity.ZdLoginLog;
import com.sunspring.zdcall.mapper.master.LoginLogMapper;
import com.sunspring.zdcall.service.LoginLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.util.List;

/**
 * @author wulei
 * @date 2019-01-04
 **/
@Service
@Slf4j
public class LoginLogServiceImpl implements LoginLogService {

    @Autowired
    private LoginLogMapper loginLogMapper;


    @Async
    @Override
    public void add(ZdLoginLog loginLog) {
        int result = loginLogMapper.insertSelective(loginLog);
        if (result <= 0 ) {
            log.error("记录登陆日志失败，日志信息{}",loginLog);
        }
    }

    @Override
    public List<ZdLoginLog> selectAll(Date startTime, Date endTime) {
        return loginLogMapper.selectAll(startTime,endTime);
    }
}
